﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;

namespace UI.Login
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Table tbl = new Table();
            //TextBox txtBox = new TextBox();
            //login.Controls.Add(tbl);

            //tbl.Controls.Add(TableCreator.CreateRowWithCell("Login", "topCell"));
            //tbl.Controls.Add(TableCreator.CreateRowWithTextBox("User ID:", txtBox, "cell"));
            //tbl.Controls.Add(TableCreator.CreateRowWithTextBox("Password:", txtBox, "bottomCell"));

            //tbl.Controls.Add(TableCreator.CreateRowWithCellAndButton("Log in", "loginCell"));

            Table tbl = new Table();
            login.Controls.Add(tbl);

            TableHeaderRow header = new TableHeaderRow();
            TableCell cell = new TableCell();
            header.CssClass = "loginTable";
            cell.Text = "Log in";
            header.Controls.Add(cell);
            tbl.Controls.Add(header);

            //2nd row
            TableRow row = new TableRow();
            cell = new TableCell();
            cell.Text = "User ID: ";
            row.Controls.Add(cell);

            TextBox user_box = new TextBox();
            TableCell login_cell = new TableCell();
            login_cell.Controls.Add(user_box);
            row.Controls.Add(login_cell);
            tbl.Controls.Add(row);

            //3rd row
            row = new TableRow();
            TableCell id_cell = new TableCell();
            id_cell.Text = "Password: ";
            row.Controls.Add(id_cell);

            TableCell psw_cell = new TableCell();
            TextBox psw_box = new TextBox();
            psw_cell.Controls.Add(psw_box);
            row.Controls.Add(psw_cell);
            tbl.Controls.Add(row);

            // btn row
            row = new TableRow();
            TableCell btn_cell = new TableCell();
            btn_cell.Controls.Add(btn);
            row.Controls.Add(btn_cell);
            tbl.Controls.Add(row);

        }


        public void Login_Command(object sender, EventArgs e)
        {
             // Get the current Mode property.-->
            var configuration = WebConfigurationManager.OpenWebConfiguration("/"); 
            var authenticationSection = (AuthenticationSection)configuration.GetSection("system.web/authentication");
            // Set the Mode property to Windows.-->
            if (authenticationSection.Mode == AuthenticationMode.Forms)
            {

                btn.PostBackUrl = "~/Administration.aspx";
            }
        }
    }   
}